﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 飞机大战.Properties;

namespace 飞机大战
{
    class PlaneHero : PlaneFather
    {
        /// <summary>
        /// 导入玩家飞机的图片
        /// </summary>
        private static Image imgPlane = Resources.hero1;

        /// <summary>
        /// 调用父类的构造函数
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="speed"></param>
        /// <param name="life"></param>
        /// <param name="dir"></param>
        public PlaneHero(int x, int y, int speed, int life, Direction dir) : base(x, y, imgPlane, speed, life, dir)
        { }

        /// <summary>
        /// 重写Game中的抽象函数Draw,将自己绘制到屏幕上
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            g.DrawImage(imgPlane, this.X, this.Y, this.Width, this.Height);
        }

        public void mousemove(MouseEventArgs e)
        {
            this.X = e.X;
            this.Y = e.Y;
        }

        /// <summary>
        /// 开炮函数
        /// </summary>
        public void Fire()
        {
            //初始化玩家子弹到游戏中
            SingleObject.GetSingle().AddGameObject(new HeroBullet(this, 10, 1));
        }

        public override void IsOver()
        {
            SingleObject .GetSingle ().AddGameObject (new HeroBoom(this.X ,this.Y));
        }
    }
}
